package com.zhss.ddd.lottery.draw.activity.api;

import com.zhss.ddd.lottery.draw.activity.vo.DrawLotteryContext;
import lombok.Data;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * 抽奖活动实体的引用  负责把底层的RPC屏蔽掉
 */
@Component
@Scope("prototype")
@Data
public class LotteryDrawActivityRef implements ILotteryDrawActivity{



    /**
     * 抽奖活动服务
     */
    @Reference(version = "1.0.0",
            interfaceClass = ILotteryDrawActivity.class,
            cluster = "failfast")
    private LotteryDrawActivityApi lotteryDrawActivityService;

    /**
     * 抽奖活动实体标识符
     */
    private Long id;

    /**
     * 获取抽奖的上下文
     */
    @Override
    public DrawLotteryContext getContext() {
        return lotteryDrawActivityService.getContext(id);
    }
}
